﻿@namespace MudBlazor.Charts

<g class="svg-tooltip" style="pointer-events: none;">
    <defs>
        <filter id="text-shadow" x="-50%" y="-50%" width="200%" height="200%">
            <feDropShadow dx="0" dy="0" stdDeviation="1.0" flood-color="black" flood-opacity="1" />
        </filter>
    </defs>

    <!-- Triangle stroke -->
    @if (ShowTriangle)
    {
        <polygon points="@_triangleBorderPoints" 
                 fill="@Color" 
                 stroke="white" 
                 stroke-width="@TriangleStrokeWidth"/>
    }

    <!-- Background -->
    <rect x="@ToS(_backgroundBBox.X)"
          y="@ToS(_backgroundBBox.Y)"
          width="@ToS(_backgroundBBox.Width)"
          height="@ToS(_backgroundBBox.Height)"
          rx="4"
          ry="4"
          fill="@Color"
          stroke="white"
          stroke-width="@StrokeWidth"/>

    <!-- Triangle fill -->
    @if (ShowTriangle)
    {
        <polygon points="@_triangleBackgroundPoints" 
                 fill="@Color"/>
    }

    <!-- Text -->
    <text @ref="_text"
          x="@ToS(_textBbox.X)"
          y="@ToS(_textBbox.Y - (HasSubtitle ? _textBbox.Height : 0))"
          font-size="@FontSize"
          fill="@FontColor"
          text-anchor="middle"
          stroke="black"
          stroke-width="0.8"
          paint-order="stroke"
          filter="url(#text-shadow)">
        <tspan x="@ToS(_textBbox.X)" dy="-.3em">@Title</tspan>
        @if (HasSubtitle)
        {
            <tspan x="@ToS(_textBbox.X)" dy="@ToS(_textBbox.Height)">@Subtitle</tspan>
        }
    </text>
</g>
